package com.arron.algorithm.huawei.中等;

import java.util.*;
import java.util.stream.Collectors;


public class 迷宫问题 {


    LinkedList<int[]> list = new LinkedList();

    public static void main(String[] args) {

        迷宫问题 mazep = new 迷宫问题();
        String str = "12ASAD";
        List<Character> list = new ArrayList<>();
        for(Character c: str.toCharArray()){
            list.add(c);
        }

        list.stream().sorted((a,b)->Character.toLowerCase(a)-Character.toLowerCase(b)).collect(Collectors.toList());


        int maze[][] = {
                {0, 1, 0, 0, 0},
                {0, 1, 1, 1, 0},
                {0, 0, 0, 0, 0},
                {0, 1, 1, 1, 0},
                {0, 0, 0, 1, 0}
        };

        mazep.mazePath(maze,0,0);
    }


    public void mazePath(int[][] maze,int i,int j){


        if (i==maze.length || j==maze[0].length || maze[i][j] == 1){
            return;
        }


//        System.out.println(i+","+j);
        list.addLast(new int[]{i,j});
        //向下走
        mazePath(maze,i+1,j);

        //向右走
        mazePath(maze,i,j+1);

        if (i==maze.length-1 && j==maze[0].length-1){
            for (int[] ints : list) {
                System.out.println(Arrays.toString(ints));
            }
        }

        list.removeLast();

    }






}
